import java.util.Scanner;

public class Question02 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("年");
        int year = scanner.nextInt();
        System.out.println("月");
        int month = scanner.nextInt();
        System.out.println("日");
        int day = scanner.nextInt();
        int sum = 0; // 总天数
        switch (month) {
            case 12:
                sum += 30;
            case 11:
                sum += 31;
            case 10:
                sum += 30;
            case 9:
                sum += 31;
            case 8:
                sum += 31;
            case 7:
                sum += 30;
            case 6:
                sum += 31;
            case 5:
                sum += 30;
            case 4:
                sum += 31;
            case 3:
                sum += 28;
                if ((year % 100 != 0 && year % 4 == 0) || year % 400 == 0){
                    // 如果是闰年 比平年 多一天
                    sum += 1;
                }
            case 2:
                sum += 31;
            case 1:
                sum += day;
                
        }

        System.out.println("第" + sum + "天");
    }
}
